<?php 
/****
布尔教育 高端PHP培训
培  训: http://www.itbool.com
论  坛: http://www.zixue.it
****/

class Mysql {
	public $link;
	//链接数据库

	public function __construct(){
		$this->conn();
	}

	public function conn() {
		$cfg = array(
			'host' => 'localhost',
			'user' => 'root',
			'password' => '',
			'db' => 'blog',
			'charset' => 'utf8'
			);

		$this->link = mysqli_connect($cfg['host'],$cfg['user'],$cfg['password'],$cfg['db']);
		$sql = 'set names '. $cfg['charset'];
		mysqli_query($this->link,$sql);
	}
	public function query($sql) {
		return mysqli_query($this->link,$sql);
	}
	public function getAll($sql){
		$data = array();
		$res = $this->query($sql);
		while($row = mysqli_fetch_assoc($res)) {
			$data[] = $row;
		}
		return $data;
		
	}
}
$mysql = new Mysql();

$a = $mysql->getAll('select * from art');
var_dump($a);
?>